<template>
  <table :id="id">
    <thead>
      <tr>
        <th v-for="(head,index) in heads" :key="index">{{head}}</th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="(r,ri) in rows" :key="ri">
        <td v-for="(name,di) in r" :key="di">{{name}}</td>
      </tr>
    </tbody>
  </table>
</template>

<script>
import { export_table_to_excel } from "@utils/export2table";

export default {
  props: {
    heads: {
      type: Array,
      default: () => []
    },
    rows: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      id: ""
    };
  },
  created() {
    this.id = "export_" + new Date();
  },
  methods: {
    export(fileName) {
      export_table_to_excel(this.id, fileName);
    }
  }
};
</script>

<style>
</style>